In general, a managed runtime environment may expect that objects are strongly-typed. For instance, a method which expects to receive an instance of “Class A” cannot operate on an instance of “Class B”—that is, unless the instance of “Class B” can be converted to an instance of “Class A” beforehand. Such a runtime environment can take type identity seriously: even two types that differ only by version number may be considered unique. This distinction is necessary because methods designed to operate on a type of version 1 may or may not work with an instance of version 2.
A problem may occur when runtime environment's strict type-safety rules block a call from occurring when the two objects are not significantly different. For example, if the only thing that changed between two versions was a version number, or if the changes between versions were strictly additive, then there is no reason that a method that expects a version 1 type can't operate on an equivalent type of version 2. To enable these scenarios, it would be advantageous to weaken the type-safety of a runtime environment in a controlled manner so that a caller can perform the same actions on either version of the type.
This may be accomplished by using two mechanisms in conjunction. The first mechanism may create an adapter that abstracts an object into a set of reflective interfaces (which in general terms may be referred to as “contracts”). These interfaces can be used to describe the object and to invoke its members without knowing the type of the object itself. This may be sufficient to address the problem of versioning: it allows the same code to work regardless of the version of the target object. However, it requires performing a complicated set of method invocations on the interfaces to perform even the most simple method call. Thus, one of the many problems addressed by the present subject matter is how to make a series of calls on reflective interfaces appear in code as a simple method calls, allowing objects of different versions and types to communicate with one another.